<%@page import="org.springframework.scheduling.annotation.Scheduled"%>
<%@page import="org.springframework.security.core.context.SecurityContextHolder"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	UserInfo user = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	String username = user.getUsername();
	DutyForm form = (DutyForm) request.getAttribute("command");
	String editSiteId = form.getSiteId();
	String editDeptId = form.getDeptId();
	TblOaDutySchedule schedule = null;
	if (null != request.getAttribute("schedule")){
		schedule = (TblOaDutySchedule) request.getAttribute("schedule");
	}
	String siteId = schedule.getSiteId()!=null?schedule.getSiteId():"";
	String deptId = schedule.getDeptId()!=null?schedule.getDeptId():"";
	String scheduleId = schedule.getScheduleId()!=null?schedule.getScheduleId():"";
	String telNo = schedule.getTelNo()!=null?schedule.getTelNo():"";
	String startTime = schedule.getStartTime()!=null?schedule.getStartTime():"";
	String endTime = schedule.getEndTime()!=null?schedule.getEndTime():"";
%>

<style>
	.selectHour-split{
		padding:0 2px;
		margin-right:5px;	
	}
	.selectMinute-split{
		padding:0 2px;
	}
</style>

<div>
	<form id="editScheduleForm" target="_coreIframe" method="post" action="<%=request.getContextPath()%>/duty/doEditSchedule" 
		onsubmit="return mySubmit()" enctype="multipart/form-data">
		<div class="breadcrumb">
			<div class="bcIcon"></div>
			<ul class="bcNav">
				<li>值班班次管理</li>
			</ul>
		</div>
		<table class="formTable">
			<tr>
				<td class="tdTitle">所属公司：</td>
				<td>
					<select id="siteList" class="easyui-combobox" style="width:100px;"></select>
					<span class="errorTipWrap" id="errorTip_siteid"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">部门：</td>
				<td>
					<select id="deptList" class="easyui-combobox" style="width:100px;"></select>
					<span class="errorTipWrap" id="errorTip_deptid"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">班次：</td>
				<td>
					<select id="scheduleList" class="easyui-combobox" style="width:100px;"></select>
					<span class="errorTipWrap" id="errorTip_userid"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">开始时间：</td>
				<td>
				<select id="startTime" class="easyui-combobox" name="startTime" style="width:100px;"></select>
				<span class="errorTipWrap" id="errorTip_startDate"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">结束时间：</td>
				<td>
				<select id="endTime" class="easyui-combobox" name="endTime" style="width:100px;"></select>
				<span class="errorTipWrap" id="errorTip_endDate"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">部门电话：</td>
				<td>
					<select id="telNo" class="easyui-combobox" name="deptTelNo" style="width:100px;"></select>
					<span class="errorTipWrap" id="errorTip_userid"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle"></td>
				<td>
					<div>
						<input class="input-btn-microsoft" type="submit" value="提交">
						<a class="a-btn-microsoft" href="javascript:XF.Duty.manageSchedule()">取消</a>
					</div>
				</td>
			</tr>
		</table>
		<input type="hidden" value="<%=EncrypTool.encode(scheduleId+"") %>" name="scheduleId"> 	
		<input type="hidden" value="<%=username %>" name="moifyUserId">
		<input type="hidden" value="<%=siteId %>" name="siteId">
		<input type="hidden" value="<%=deptId %>" name="deptId">
	</form>
	<iframe id="_coreIframe" name="_coreIframe" style="display: none;"></iframe>
</div>

<script>
XF.Duty.DefaultSiteId = '<%=siteId %>';
$('#siteList').combobox({
	/* url:global.contextPath + '/company/siteList', 
	method:'get',*/
	valueField:'siteid',
	textField:'sitename',
	disabled:true,
});

$('#deptList').combobox({
	url:global.contextPath + '/company/deptList',
	valueField:'dictid',
	textField:'dictname',							
	method:'get',
	disabled:true,
});

$("#scheduleList").combobox({
	url:global.contextPath + '/duty/datagridSchedules?siteId=' + '<%=siteId %>' + '&deptId='+'<%=deptId %>',
	valueField:'scheduleId',
	textField:'scheduleName',
	method:'get',
	disabled:true,
});

$("#telNo").combobox({
	url:global.contextPath + '/duty/datagridDeptTelNo?deptId=' + '<%=deptId %>',
	valueField:'telNo',
	textField:'telNo',
	editable:true,
	required:true
});

$("#startTime").combobox({
	url:global.contextPath + '/duty/scheduleTime' + '<%=scheduleId %>',
	valueField:'startTime',
	textField:'startTime',
	editable:true,
	required:true
});

$("#endTime").combobox({
	url:global.contextPath + '/duty/scheduleTime' + '<%=scheduleId %>',
	valueField:'endTime',
	textField:'endTime',
	editable:true,
	required:true
});

$('#siteList').combobox('setValue', '<%=siteId%>');
$('#siteList').combobox('setText', '<%=user.getSiteName()%>');
var dept = '<%=deptId%>';
	if(dept!='D999'){
		$('#deptList').combobox('setValue', '<%=deptId%>');
	}else{
		$('#deptList').combobox('setValue', '');
	}
$('#scheduleList').combobox('setValue', '<%=scheduleId%>');
$('#telNo').combobox('setValue', '<%=telNo%>');
$('#startTime').combobox('setValue', '<%=startTime%>');
$('#endTime').combobox('setValue', '<%=endTime%>');

function mySubmit(){
	$('#telNo').combobox('setValue', $('#telNo').combobox('getText'));
	$('#startTime').combobox('setValue', $('#startTime').combobox('getText'));
	$('#endTime').combobox('setValue', $('#endTime').combobox('getText'));
	return true;
}
</script>


			
